home *** CD-ROM | disk | FTP | other *** search
- OSTREAM(3C) Last changed: 1-7-99
-
-
- NNAAMMEE
- oossttrreeaamm - Formatted and unformatted output
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<iioossttrreeaamm..hh>>
-
- ttyyppeeddeeff lloonngg ssttrreeaammooffff,, ssttrreeaammppooss;;
- ccllaassss iiooss {{
- ppuubblliicc::
- eennuumm sseeeekk__ddiirr {{ bbeegg,, ccuurr,, eenndd }};;
- eennuumm ooppeenn__mmooddee {{ iinn,, oouutt,, aattee,, aapppp,, ttrruunncc,, nnooccrreeaattee,, nnoorreeppllaaccee }}
- ;;
- eennuumm {{ sskkiippwwss==0011,,
- lleefftt==0022,, rriigghhtt==0044,, iinntteerrnnaall==001100,,
- ddeecc==002200,, oocctt==004400,, hheexx==00110000,,
- sshhoowwbbaassee==00220000,, sshhoowwppooiinntt==00440000,, uuppppeerrccaassee==0011000000,,
- sshhoowwppooss==0022000000,,
- sscciieennttiiffiicc==0044000000,, ffiixxeedd==001100000000,,
- uunniittbbuuff==002200000000,, ssttddiioo==004400000000 }};;
- //// aanndd lloottss ooff ootthheerr ssttuuffff,, sseeee iiooss((33CC)) ......
- }} ;;
-
- ccllaassss oossttrreeaamm :: ppuubblliicc iiooss {{
- ppuubblliicc::
- oossttrreeaamm((ssttrreeaammbbuuff**));;
- oossttrreeaamm&& fflluusshh(());;
- iinntt ooppffxx(());;
- oossttrreeaamm&& ppuutt((cchhaarr));;
- oossttrreeaamm&& sseeeekkpp((ssttrreeaammppooss));;
- oossttrreeaamm&& sseeeekkpp((ssttrreeaammooffff,, sseeeekk__ddiirr));;
- ssttrreeaammppooss tteellllpp(());;
- oossttrreeaamm&& wwrriittee((ccoonnsstt cchhaarr** ppttrr,, iinntt nn));;
- oossttrreeaamm&& wwrriittee((ccoonnsstt uunnssiiggnneedd cchhaarr** ppttrr,, iinntt nn));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((ccoonnsstt cchhaarr**));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((cchhaarr));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((sshhoorrtt));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((iinntt));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((lloonngg));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((ffllooaatt));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((ddoouubbllee));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((uunnssiiggnneedd cchhaarr));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((uunnssiiggnneedd sshhoorrtt));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((uunnssiiggnneedd iinntt));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((uunnssiiggnneedd lloonngg));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((vvooiidd**));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((ssttrreeaammbbuuff**));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((oossttrreeaamm&& ((**))((oossttrreeaamm&&))));;
- oossttrreeaamm&& ooppeerraattoorr<<<<((iiooss&& ((**))((iiooss&&))));;
- }};;
-
- ccllaassss oossttrreeaamm__wwiitthhaassssiiggnn {{
- oossttrreeaamm__wwiitthhaassssiiggnn(());;
- iissttrreeaamm&& ooppeerraattoorr==((iissttrreeaamm&&));;
- iissttrreeaamm&& ooppeerraattoorr==((ssttrreeaammbbuuff**));;
- }};;
-
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn ccoouutt;;
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cceerrrr;;
- eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cclloogg;;
-
- oossttrreeaamm&& eennddll((oossttrreeaamm&&)) ;;
- oossttrreeaamm&& eennddss((oossttrreeaamm&&)) ;;
- oossttrreeaamm&& fflluusshh((oossttrreeaamm&&)) ;;
- iiooss&& ddeecc((iiooss&&)) ;;
- iiooss&& hheexx((iiooss&&)) ;;
- iiooss&& oocctt((iiooss&&)) ;;
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- oossttrreeaamm supports insertion (storing) into a ssttrreeaammbbuuff. This is
- commonly referred to as an output operation.
-
- In the following descriptions of oossttrreeaamm member functions and related
- functions, assume the following:
-
- * _o_u_t_s is an oossttrreeaamm.
-
- * _o_u_t_s_w_a is an oossttrreeaamm__wwiitthhaassssiiggnn.
-
- * _o_u_t_s_p is an oossttrreeaamm**.
-
- * _c is a cchhaarr.
-
- * _p_t_r is a cchhaarr** or uunnssiiggnneedd cchhaarr**.
-
- * _s_b is a ssttrreeaammbbuuff**
-
- * _i and _n are iinntts.
-
- * _p_o_s is a ssttrreeaammppooss.
-
- * _o_f_f is a ssttrreeaammooffff.
-
- * _d_i_r is a sseeeekk__ddiirr.
-
- * _m_a_n_i_p is a function with type oossttrreeaamm&& ((**))((oossttrreeaamm&&)).
-
- CCoonnssttrruuccttoorrss aanndd AAssssiiggnnmmeenntt
- oossttrreeaamm((_s_b))
- initializes iiooss state variables and associates buffer _s_b with the
- oossttrreeaamm.
-
- oossttrreeaamm__wwiitthhaassssiiggnn(())
- Does no initialization. This allows a file static variable of
- this type (ccoouutt, for example) to be used before it is
- constructed, provided it is assigned to first.
-
- _o_u_t_s_w_a==_s_b
- Associates _s_b with _s_w_a and initializes the entire state of
- _o_u_t_s_w_a.
-
- _i_n_s_w_a==_i_n_s
- Associates _i_n_s-->>rrddbbuuff(()) _w_i_t_h _s_w_a _a_n_d _i_n_i_t_i_a_l_i_z_e_s _t_h_e _e_n_t_i_r_e _s_t_a_t_e
- _o_f _o_u_t_s_w_a.
-
- OOuuttppuutt pprreeffiixx ffuunnccttiioonn::
- _i==_o_u_t_s..ooppffxx(())
- If _o_u_t_s's error state is nonzero, returns immediately. If
- _o_u_t_s..ttiiee(()) _i_s _n_o_n-_n_u_l_l, _i_t _i_s _f_l_u_s_h_e_d. _R_e_t_u_r_n_s _n_o_n-_z_e_r_o _e_x_c_e_p_t
- _w_h_e_n _o_u_t_s'_s _e_r_r_o_r _s_t_a_t_e _i_s _n_o_n_z_e_r_o.
-
- OOuuttppuutt ssuuffffiixx ffuunnccttiioonn
- oossffxx(())
- Performs ``suffix'' actions before returning from inserters. If
- iiooss::::uunniittbbuuff is set, oossffxx(()) flushes the oossttrreeaamm. If iiooss::::ssttddiioo
- is set, oossffxx(()) flushes ssttddoouutt and ssttddeerrrr.
-
- oossffxx(()) is called by all predefined inserters, and should be called by
- user-defined inserters as well, after any direct manipulation of the
- ssttrreeaammbbuuff. It is not called by the binary output functions.
-
- FFoorrmmaatttteedd OOuuttppuutt FFuunnccttiioonnss ((iinnsseerrtteerrss))
- _o_u_t_s<<<<_x
- First calls _o_u_t_s..ooppffxx(()) _a_n_d _i_f _t_h_a_t _r_e_t_u_r_n_s _0, _d_o_e_s _n_o_t_h_i_n_g.
- _O_t_h_e_r_w_i_s_e _i_n_s_e_r_t_s _a _s_e_q_u_e_n_c_e _o_f _c_h_a_r_a_c_t_e_r_s _r_e_p_r_e_s_e_n_t_i_n_g _x _i_n_t_o
- _o_u_t_s..rrddbbuuff(()). _E_r_r_o_r_s _a_r_e _i_n_d_i_c_a_t_e_d _b_y _s_e_t_t_i_n_g _t_h_e _e_r_r_o_r _s_t_a_t_e _o_f
- _o_u_t_s. _o_u_t_s _i_s _a_l_w_a_y_s _r_e_t_u_r_n_e_d.
-
- _x is converted into a sequence of characters (its representation)
- according to rules that depend on _x's type and _o_u_t_s's format
- state flags and variables (see iiooss(3C)). Inserters are defined
- for the following types, with conversion rules as described
- below:
-
- cchhaarr**
- The representation is the sequence of characters up to (but
- not including) the terminating null of the string _x points
- at.
-
- _a_n_y _i_n_t_e_g_r_a_l _t_y_p_e except cchhaarr _a_n_d uunnssiiggnneedd cchhaarr
- If _x is positive the representation contains a sequence of
- decimal, octal, or hexadecimal digits with no leading zeros
- according to whether iiooss::::ddeecc, iiooss::::oocctt, or iiooss::::hheexx,
- respectively, is set in iiooss's format flags. If none of
- those flags are set, conversion defaults to decimal. If _x
- is zero, the representation is a single zero character(00).
- If _x is negative, decimal conversion converts it to a minus
- sign (--) followed by decimal digits. If _x is positive and
- iiooss::::sshhoowwppooss is set, decimal conversion converts it to a
- plus sign (++) followed by decimal digits. The other
- conversions treat all values as unsigned. If iiooss::::sshhoowwbbaassee
- is set in _i_o_s's format flags, the hexadecimal representation
- contains 00xx before the hexadecimal digits, or 00XX if
- iiooss::::uuppppeerrccaassee is set. If iiooss::::sshhoowwbbaassee is set, the octal
- representation contains a leading 0.
-
- vvooiidd**
- Pointers are converted to integral values and then converted
- to hexadecimal numbers as if iiooss::::sshhoowwbbaassee were set.
-
- ffllooaatt, ddoouubbllee
- The arguments are converted according to the current values
- of _o_u_t_s..pprreecciissiioonn(()), _o_u_t_s..wwiiddtthh(()) _a_n_d _o_u_t_s'_s _f_o_r_m_a_t _f_l_a_g_s
- iiooss::::sscciieennttiiffiicc, iiooss::::ffiixxeedd, _a_n_d iiooss::::uuppppeerrccaassee. (_S_e_e
- iiooss(_3_C).) _T_h_e _d_e_f_a_u_l_t _v_a_l_u_e _f_o_r _o_u_t_s..pprreecciissiioonn(()) _i_s _6. _I_f
- _n_e_i_t_h_e_r iiooss::::sscciieennttiiffiicc _n_o_r iiooss::::ffiixxeedd _i_s _s_e_t, _e_i_t_h_e_r _f_i_x_e_d
- _o_r _s_c_i_e_n_t_i_f_i_c _n_o_t_a_t_i_o_n _i_s _c_h_o_s_e_n _f_o_r _t_h_e _r_e_p_r_e_s_e_n_t_a_t_i_o_n,
- _d_e_p_e_n_d_i_n_g _o_n _t_h_e _v_a_l_u_e _o_f _x.
-
- cchhaarr, uunnssiiggnneedd cchhaarr
- No special conversion is necessary.
-
- After the representation is determined, padding occurs. If
- _o_u_t_s..wwiiddtthh(()) _i_s _g_r_e_a_t_e_r _t_h_a_n _0 _a_n_d _t_h_e _r_e_p_r_e_s_e_n_t_a_t_i_o_n _c_o_n_t_a_i_n_s
- _f_e_w_e_r _t_h_a_n _o_u_t_s..wwiiddtthh(()) _c_h_a_r_a_c_t_e_r_s, _t_h_e_n _e_n_o_u_g_h _o_u_t_s..ffiillll(())
- _c_h_a_r_a_c_t_e_r_s _a_r_e _a_d_d_e_d _t_o _b_r_i_n_g _t_h_e _t_o_t_a_l _n_u_m_b_e_r _o_f _c_h_a_r_a_c_t_e_r_s _t_o
- iiooss..wwiiddtthh(()). _I_f iiooss::::lleefftt _i_s _s_e_t _i_n iiooss'_s _f_o_r_m_a_t _f_l_a_g_s, _t_h_e
- _s_e_q_u_e_n_c_e _i_s _l_e_f_t-_a_d_j_u_s_t_e_d, _t_h_a_t _i_s, _c_h_a_r_a_c_t_e_r_s _a_r_e _a_d_d_e_d _a_f_t_e_r
- _t_h_e _c_h_a_r_a_c_t_e_r_s _d_e_t_e_r_m_i_n_e_d _a_b_o_v_e. _I_f iiooss::::rriigghhtt _i_s _s_e_t, _t_h_e
- _p_a_d_d_i_n_g _i_s _a_d_d_e_d _b_e_f_o_r_e _t_h_e _c_h_a_r_a_c_t_e_r_s _d_e_t_e_r_m_i_n_e_d _a_b_o_v_e. _I_f
- iiooss::::iinntteerrnnaall _i_s _s_e_t, _t_h_e _p_a_d_d_i_n_g _i_s _a_d_d_e_d _a_f_t_e_r _a_n_y _l_e_a_d_i_n_g _s_i_g_n
- _o_r _b_a_s_e _i_n_d_i_c_a_t_i_o_n _a_n_d _b_e_f_o_r_e _t_h_e _c_h_a_r_a_c_t_e_r_s _t_h_a_t _r_e_p_r_e_s_e_n_t _t_h_e
- _v_a_l_u_e. iiooss..wwiiddtthh(()) _i_s _r_e_s_e_t _t_o _0, _b_u_t _a_l_l _o_t_h_e_r _f_o_r_m_a_t _v_a_r_i_a_b_l_e_s
- _a_r_e _u_n_c_h_a_n_g_e_d. _T_h_e _r_e_s_u_l_t_i_n_g _s_e_q_u_e_n_c_e (_p_a_d_d_i_n_g _p_l_u_s
- _r_e_p_r_e_s_e_n_t_a_t_i_o_n) _i_s _i_n_s_e_r_t_e_d _i_n_t_o _o_u_t_s..rrddbbuuff(()).
-
- _o_u_t_s<<<<_s_b
- If _o_u_t_s..ooppffxx(()) _r_e_t_u_r_n_s _n_o_n-_z_e_r_o, _t_h_e _s_e_q_u_e_n_c_e _o_f _c_h_a_r_a_c_t_e_r_s _t_h_a_t
- _c_a_n _b_e _f_e_t_c_h_e_d _f_r_o_m _s_b _a_r_e _i_n_s_e_r_t_e_d _i_n_t_o _o_u_t_s..rrddbbuuff(()). _I_n_s_e_r_t_i_o_n
- _s_t_o_p_s _w_h_e_n _n_o _m_o_r_e _c_h_a_r_a_c_t_e_r_s _c_a_n _b_e _f_e_t_c_h_e_d _f_r_o_m _s_b. _N_o _p_a_d_d_i_n_g
- _i_s _p_e_r_f_o_r_m_e_d. _A_l_w_a_y_s _r_e_t_u_r_n_s _o_u_t_s.
-
- UUnnffoorrmmaatttteedd OOuuttppuutt FFuunnccttiioonnss
- _o_u_t_s_p==&&_o_u_t_s..ppuutt((cc))
- Inserts _c into _o_u_t_s..rrddbbuuff(()). _S_e_t_s _t_h_e _e_r_r_o_r _s_t_a_t_e _i_f _t_h_e
- _i_n_s_e_r_t_i_o_n _f_a_i_l_s.
-
- _o_u_t_s_p==&&_o_u_t_s..wwrriittee((_s,,_n))
- Inserts the _n characters starting at _s into _o_u_t_s..rrddbbuuff(()). _T_h_e_s_e
- _c_h_a_r_a_c_t_e_r_s _m_a_y _i_n_c_l_u_d_e _z_e_r_o_s (_i._e., _s _n_e_e_d _n_o_t _b_e _a _n_u_l_l
- _t_e_r_m_i_n_a_t_e_d _s_t_r_i_n_g).
-
- OOtthheerr MMeemmbbeerr FFuunnccttiioonnss
- _o_u_t_s_p==&&_o_u_t_s..fflluusshh(())
- Storing characters into a streambuf does not always cause them to
- be consumed (e.g., written to the external file) immediately.
- fflluusshh(()) causes any characters that may have been stored but not
- yet consumed to be consumed by calling _o_u_t_s..rrddbbuuff(())-->>ssyynncc.
-
- _o_u_t_s<<<<mmaanniipp
- Equivalent to mmaanniipp((_o_u_t_s)). _S_y_n_t_a_c_t_i_c_a_l_l_y _t_h_i_s _l_o_o_k_s _l_i_k_e _a_n
- _i_n_s_e_r_t_i_o_n _o_p_e_r_a_t_i_o_n, _b_u_t _s_e_m_a_n_t_i_c_a_l_l_y _i_t _d_o_e_s _a_n _a_r_b_i_t_r_a_r_y
- _o_p_e_r_a_t_i_o_n _r_a_t_h_e_r _t_h_a_n _c_o_n_v_e_r_t_i_n_g mmaanniipp _t_o _a _s_e_q_u_e_n_c_e _o_f
- _c_h_a_r_a_c_t_e_r_s _a_s _d_o _t_h_e _i_n_s_e_r_t_i_o_n _o_p_e_r_a_t_o_r_s. _P_r_e_d_e_f_i_n_e_d
- _m_a_n_i_p_u_l_a_t_o_r_s _a_r_e _d_e_s_c_r_i_b_e_d _b_e_l_o_w.
-
- PPoossiittiioonniinngg FFuunnccttiioonnss
- _o_u_t_s_p==&&_i_n_s..sseeeekkpp((_o_f_f,,_d_i_r))
- Repositions _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r. _S_e_e ssbbuuff..ppuubb(_3_C) _f_o_r _a
- _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
-
- _o_u_t_s_p==&&_o_u_t_s..sseeeekkpp((_p_o_s))
- Repositions _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r. _S_e_e ssbbuuff..ppuubb(_3_C) _f_o_r _a
- _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
-
- _p_o_s==_o_u_t_s..tteellllpp(())
- The current position of _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r. _S_e_e
- ssbbuuff..ppuubb(_3_C) _f_o_r _a _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
-
- MMaanniippuullaattoorrss
- _o_u_t_s<<<<eennddll
- Ends a line by inserting a newline character and flushing.
-
- _o_u_t_s<<<<eennddss
- Ends a string by inserting a null (0) character.
-
- _o_u_t_s<<<<fflluusshh
- Flushes _o_u_t_s.
-
- _o_u_t_s<<<<ddeecc
- Sets the conversion base format flag to 10. See iiooss(3C).
-
- _o_u_t_s<<<<hheexx
- Sets the conversion base format flag to 16. See iiooss(3C).
-
- _o_u_t_s<<<<oocctt
- Sets the conversion base format flag to 8. See iiooss(3C).
-
- SSEEEE AALLSSOO
- iiooss(3C), ssbbuuff..ppuubb(3C), mmaanniipp(3C)
-
- This man page is available only online.
-